package cn.jervain.nut.auth.core.provider;

import cn.jervain.nut.auth.core.authentication.Authentication;
import cn.jervain.nut.auth.core.authentication.SimpleAuthentication;
import org.springframework.http.HttpMethod;

public class InMemoryAuthProvider extends AuthProvider<Object> {

    private String username = "admin";
    private String password = "admin";

    public InMemoryAuthProvider() {
        super();
    }

    public InMemoryAuthProvider(
            String usernameParam,
            String passwordParam,
            String authEndpoint,
            HttpMethod authMethod,
            String username,
            String password
    ) {
        super(usernameParam, passwordParam, authEndpoint, authMethod);
        this.username = username;
        this.password = password;
    }

    @Override
    protected Authentication<Object> retrieveUser(String username) {
        SimpleAuthentication<Object> authentication = new SimpleAuthentication<>();
        authentication.setUsername(this.username);
        authentication.setPassword(this.password);
        authentication.setDetail(new Object());
        return authentication;
    }

}
